home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / door / twview93.zip / PATHSTUF.INC < prev    next >
Text File  |  1992-05-10  |  2KB  |  74 lines

  1. {procedure PrintPath( var home : sector; sec : sector );
  2. var
  3.   dummy : text;
  4. begin
  5.   if home <> sec then
  6.     PrintPath( home, distances[ sec ].s );
  7.   displaySector( sec, 'Dist', error, false, dummy )
  8. end;
  9. }
  10. procedure PathLength;
  11. var
  12.   s1, s2 : sector;
  13.   len    : integer;
  14. begin
  15.   write('Distance between which two sectors? ');
  16.   readln( s1, s2 );
  17.   if space.sectors[ s1 ].number <> Unexplored then
  18.     begin
  19.       len := FixPath( s1, s2 );
  20.       if len = Error then
  21.         writeln('You don''t know how to get to ', s2, ' from ', s1, '!' )
  22.       else
  23.         begin
  24.           writeln('Known shortest path from ', s1, ' to ', s2, ' is ');
  25.           PrintPath( s1, s2 );
  26.           writeln;
  27.           writeln('Path is of length ', len );
  28.           readln;
  29.         end; {if finite distance}
  30.     end {visited}
  31.   else
  32.     writeln('Never visited ', s1, ' so can''t tell distances leaving it.');
  33.   if space.sectors[ s1 ].number <> UnExplored then
  34.     begin
  35.       len := FixPath( s2, s1 );
  36.       if len = Error then
  37.         writeln('You don''t know how to get to ', s1, ' from ', s2, '!' )
  38.       else
  39.         begin
  40.           writeln('Known shortest path from ', s2, ' to ', s1, ' is ');
  41.           PrintPath( s2, s1 );
  42.           writeln;
  43.           writeln('Path is of length ', len );
  44.         end; {if finite distance}
  45.     end
  46.   else
  47.     writeln('Never visited ', s2, ' so can''t tell distances leaving it.');
  48. end;
  49.  
  50. procedure NearestFighters;
  51. var
  52.   s, s1, Closest : sector;
  53. begin
  54.   write('What is your current sector?  ');
  55.   readln( s );
  56.   TwoWayDistances( s, distances, false, true );
  57.   Closest := 1;
  58.   for s1 := 1 to maxSector do
  59.     if (space.sectors[ s1 ].portType = Class0) or (s1=space.dock) then
  60.       if distances[ s1 ].d = maxint then
  61.         writeln('You don''t know how to get to ', s1 )
  62.       else
  63.         begin
  64.           writeln('Path to ', s1, ' is of length ', distances[ s1 ].d );
  65.           PrintPath( s, s1 );
  66.           writeln;
  67.           readln;
  68.           if distances[ s1 ].d < distances[ Closest ].d then
  69.             Closest := s1;
  70.         end; {for if else}
  71.   writeln('The closest target for fighters is ', closest );
  72. end; {Nearest Fighters}
  73.  
  74.